var app = getApp()

Page({
  data:{
    obje:{},
    tasks : []
  },
  onLoad:function(options){
    var that = this;
    // 页面初始化 options为页面跳转所带来的参数
    console.log("景点id:"+options.id);
    var id = options.id;
    if(!id) id = 1;
    app.request("scenicespot/"+id, "GET", null, function(res){
        that.setData({
            obje : res.result
        });
    });

    app.request("scenicespot/"+id+"/activitys", "GET", null, function(res){
        that.setData({
            tasks : res.result
        });
    });

  },
  call : function(event){
    var phone = event.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },

  onActivityClick : function(event){
        var id = event.currentTarget.dataset.hi;
        wx.navigateTo({
            url: '../activity/activity?id='+id
        })
  },
  view_address_map: function () {
    var obje = this.data.obje;
    app.openMap(obje.mapCoordinates.split(",")[0],
      obje.mapCoordinates.split(",")[1],
      obje.name, obje.address);
  }

})